package com.itheima.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.dubbo.dao.QuestionDao;
import com.itheima.model.domain.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi {
    @Autowired
    private QuestionDao questionDao;

    @Override
    public Question findById(Long userId) {
        LambdaQueryWrapper<Question> lqw = Wrappers.lambdaQuery(Question.class);
        lqw.eq(Question::getId, userId);
        Question question = questionDao.selectOne(lqw);
        return question;
    }

    @Override
    public void saveQustion(Question question) {
        questionDao.insert(question);
    }

    @Override
    public void update(Question question) {
        questionDao.updateById(question);
    }
}
